package com.mrd.gtimp.business.repository;

import com.mrd.gtimp.business.entity.DeclarationOffer;
import com.mrd.spring.repository.BaseRepository;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * application name: gtimp
 * <p>
 * copyright: Copyright@2012 明睿达科技有限公司
 */

/**
 * @author yangyl
 */
public interface DeclarationOfferDao extends BaseRepository<DeclarationOffer, String> {
    /**
     * 根据供应商id查找当前生效的报价
     */
    @Query(value = "from #{#entityName} offer where offer.state='OS05' and offer.declaration_company_id=:supCompanyId and offer.price_begin_time <= :now and offer.price_end_time >= :now order by review_date desc")
    List<DeclarationOffer> findValidOffer(@Param("supCompanyId") String supCompanyId, @Param("now") Date date);
}
